package com.kdx.cloud.common.runtime;


/**
 * 登录信息访问工具类
 * 
 * @author litianshen
 * 
 */
public final class LoginManager {
	private final static ThreadLocal<Login> loginTL = new ThreadLocal<Login>();

	public static void setLogin(Login login) {
		loginTL.set(login);
	}

	public static Login getLogin() {
		Login login = loginTL.get();
		if (login == null) {
			login = new Login();
			loginTL.set(login);
		}
		return login;

	}

	public static String getUserId() {
		return LoginManager.getLogin() == null ? "admin" : LoginManager
				.getLogin().getUserId();
	}

}
